/*     */ package com.zimbra.cs.service.mail;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.LogFactory;
/*     */ import com.zimbra.cs.mailbox.CalendarItem;
/*     */ import com.zimbra.cs.mailbox.MailServiceException;
/*     */ import com.zimbra.cs.mailbox.Mailbox;
/*     */ import com.zimbra.cs.mailbox.MailboxLock;
/*     */ import com.zimbra.cs.mailbox.OperationContext;
/*     */ import com.zimbra.cs.service.util.ItemId;
/*     */ import com.zimbra.cs.service.util.ItemIdFormatter;
/*     */ import com.zimbra.soap.JaxbUtil;
/*     */ import com.zimbra.soap.ZimbraSoapContext;
/*     */ import com.zimbra.soap.mail.type.GetCalendarItemRequestBase;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class GetCalendarItem
/*     */   extends CalendarRequest
/*     */ {
/*  42 */   private static final Log LOG = LogFactory.getLog(GetCalendarItem.class);
/*     */   
/*  44 */   private static final String[] TARGET_ITEM_PATH = { "id" };
/*  45 */   private static final String[] RESPONSE_ITEM_PATH = new String[0];
/*     */   
/*     */   protected String[] getProxiedIdPath(Element request)
/*     */   {
/*  49 */     return TARGET_ITEM_PATH;
/*     */   }
/*     */   
/*     */   protected boolean checkMountpointProxy(Element request)
/*     */   {
/*  54 */     return false;
/*     */   }
/*     */   
/*     */   protected String[] getResponseItemPath()
/*     */   {
/*  59 */     return RESPONSE_ITEM_PATH;
/*     */   }
/*     */   
/*     */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*     */   {
/*  64 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*  65 */     Mailbox mbox = getRequestedMailbox(zsc);
/*  66 */     OperationContext octxt = getOperationContext(zsc, context);
/*  67 */     ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
/*  68 */     GetCalendarItemRequestBase req = (GetCalendarItemRequestBase)JaxbUtil.elementToJaxb(request);
/*     */     
/*  70 */     boolean sync = req.getSync() == null ? false : req.getSync().booleanValue();
/*  71 */     boolean includeContent = req.getIncludeContent() == null ? false : req.getIncludeContent().booleanValue();
/*  72 */     boolean includeInvites = req.getIncludeInvites() == null ? true : req.getIncludeInvites().booleanValue();
/*  73 */     ItemId iid = null;
/*  74 */     String uid = req.getUid();
/*  75 */     String id = req.getId();
/*  76 */     if (uid != null) {
/*  77 */       if (id != null) {
/*  78 */         throw ServiceException.INVALID_REQUEST("either id or uid should be specified, but not both", null);
/*     */       }
/*  80 */       LOG.info("<GetCalendarItem uid=" + uid + "> " + zsc);
/*     */     } else {
/*  82 */       iid = new ItemId(id, zsc);
/*  83 */       LOG.info("<GetCalendarItem id=" + iid.getId() + "> " + zsc);
/*     */     }
/*     */     
/*     */ 
/*  87 */     int fields = -4194305;
/*  88 */     if (sync) {
/*  89 */       fields |= 0x400000;
/*     */     }
/*  91 */     Element response = getResponseElement(zsc);
/*  92 */     CalendarItem calItem = null;
/*  93 */     mbox.lock.lock(false);
/*     */     try {
/*  95 */       if (uid != null) {
/*  96 */         calItem = mbox.getCalendarItemByUid(octxt, uid);
/*  97 */         if (calItem == null) {
/*  98 */           throw MailServiceException.NO_SUCH_CALITEM(uid);
/*     */         }
/*     */       } else {
/* 101 */         calItem = mbox.getCalendarItemById(octxt, iid);
/* 102 */         if (calItem == null) {
/* 103 */           throw MailServiceException.NO_SUCH_CALITEM(iid.toString());
/*     */         }
/*     */       }
/*     */     } finally {
/* 107 */       mbox.lock.release();
/*     */     }
/* 109 */     ToXML.encodeCalendarItemSummary(response, ifmt, octxt, calItem, fields, includeInvites, includeContent);
/*     */     
/* 111 */     return response;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/GetCalendarItem.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */